<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page pageEncoding="UTF-8" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<h1>System Config</h1>
<script type="text/javascript" src="${contextPath}/static/script/jquery/jquery-1.4.2.js"></script>
<script type="text/javascript">
    function save() {
        $("input:checkbox").each(function() {
            $(this).val($(this).attr("checked"));
        });
        $("#list_hotel_form").submit();
    }
    function changeAddDetailCodeStatus(enable) {
        $("#rd1").attr("disabled", !enable);
        $("#rd2").attr("disabled", !enable);
        $("#additionalDetailCode").attr("disabled", !enable);
        if (enable) {
            $("#additionalDetailCode").attr("checked", "checked");
            $("#additionalDetailCode").val(enable);
        } else {
            $("#additionalDetailCode").attr("checked", "");
            $("#additionalDetailCode").val(!enable);
        }
    }
    $(function() {
        $("input[name='configuration.roomTypeName.value']").each(function() {
            if ($(this).attr("checked") && $(this).val() == 'ROOM_RATE_DESCRIPTION') {
                changeAddDetailCodeStatus(false);
            }
            if ($(this).attr("checked") && $(this).val() == 'ADDITIONAL_DETAIL_DESCRIPTION') {
                $("#rd1").attr("disabled", false);
                $("#rd2").attr("disabled", false);
                $("#additionalDetailCode").attr("disabled", false);
            }
        });
    });
</script>

<div class="main">
    <div class="box_side search_hotel clearfix">
        <form action="save.dhtml" id="list_hotel_form" method="post">
            <h1>Room Type Name Configuration</h1>
            <table class="table_list" cellpadding="0" cellspacing="0">
                <thead>
                <tr>
                    <th>Description</th>
                    <th>Value</th>
                    <th>Usable</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <input type="hidden" name="configuration.roomTypeName.name"
                           value="${configuration.roomTypeName.name}"/>
                    <input type="hidden" name="configuration.roomTypeName.description"
                           value="${configuration.roomTypeName.description}"/>
                    <td>${configuration.roomTypeName.description}:</td>
                    <td>
                        <input type="radio" name="configuration.roomTypeName.value"
                               value="ROOM_RATE_DESCRIPTION" onclick="changeAddDetailCodeStatus(false);"
                               <s:if
                                       test="configuration.roomTypeName.value=='ROOM_RATE_DESCRIPTION'">checked="checked"</s:if>>
                        From Room Rate Description
                        &nbsp;&nbsp;
                        <input type="radio" name="configuration.roomTypeName.value"
                               onclick="changeAddDetailCodeStatus(true);"
                               value="ADDITIONAL_DETAIL_DESCRIPTION" <s:if
                                test="configuration.roomTypeName.value!='ROOM_RATE_DESCRIPTION'">checked="checked"</s:if>>
                        From Additional Detail Description
                    </td>
                    <td>
                        <input type="checkbox" name="configuration.roomTypeName.usable"
                               value="${configuration.roomTypeName.usable}"
                               <s:if test="configuration.roomTypeName.usable">checked="checked"</s:if>/></td>
                </tr>
                <tr>
                    <input type="hidden" name="configuration.additionalDetailCode.name"
                           value="${configuration.additionalDetailCode.name}"/>
                    <input type="hidden" name="configuration.additionalDetailCode.description"
                           value="${configuration.additionalDetailCode.description}"/>
                    <td>${configuration.additionalDetailCode.description}:</td>
                    <td>
                        <input id="rd1" type="radio" name="configuration.additionalDetailCode.value" disabled="disabled"
                               value="RD1"
                               <s:if
                                       test="configuration.additionalDetailCode.value=='RD1'">checked="checked"</s:if>>
                        RD1
                        &nbsp;&nbsp;
                        <input id="rd2" type="radio" name="configuration.additionalDetailCode.value" disabled="disabled"
                               value="RD2" <s:if
                                test="configuration.additionalDetailCode.value!='RD1'">checked="checked"</s:if>>
                        RD2
                    </td>
                    <td><input id="additionalDetailCode" type="checkbox" disabled="disabled"
                               name="configuration.additionalDetailCode.usable"
                               value="${configuration.additionalDetailCode.usable}"
                               <s:if test="configuration.additionalDetailCode.usable">checked="checked"</s:if>/>
                    </td>
                </tr>
                <tr>
                    <input type="hidden" name="configuration.matchPriorityConfig.name"
                           value="${configuration.matchPriorityConfig.name}"/>
                    <input type="hidden" name="configuration.matchPriorityConfig.description"
                           value="${configuration.matchPriorityConfig.description}"/>
                    <td>${configuration.matchPriorityConfig.description}:</td>
                    <td>
                        <span>All type: CHANNEL, HOTEL, RATE_PLAN, ROOM_TYPE</span></br>
                        <span>Eg: CHANNEL; CHANNEL& HOTEL& RATE_PLAN; ROOM_TYPE</span></br>
                        <input style="font-family: Verdana;font-weight: bold" maxlength="200" size="100" name="configuration.matchPriorityConfig.value" value="${configuration.matchPriorityConfig.value}" />
                    </td>
                    <td>
                        <input id="matchPriorityConfig" type="checkbox" name="configuration.matchPriorityConfig.usable"
                               value="${configuration.matchPriorityConfig.usable}"
                               <s:if test="configuration.matchPriorityConfig.usable">checked="checked"</s:if>/>
                    </td>
                </tr>
                </tbody>
            </table>
            <p>
           <div>
                <input class="common_button" type="button" onclick="save();" value="Submit">
            </div>
        </form>
    </div>
</div>